package HUZ;

import java.util.Scanner;
import java.util.TreeSet;

public class Test3 {

    public static boolean isChar(char a) {
        if ((a >= 'A' && a <= 'Z')) {
            return true;
        }
        return false;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String right = in.nextLine();
            String fail = in.nextLine();
            TreeSet<Character> setRight = new TreeSet<>();
            TreeSet<Character> setFail = new TreeSet<>();
            //将输入的每个键进行去重存储
            for (int i = 0; i < right.length(); i++) {
                char ch = right.charAt(i);
                if(isChar(ch)){
                    String s=ch+"";
                    String s1 = s.toLowerCase();
                    //System.out.println(s1);
                    ch=s1.charAt(0);
                }
                setRight.add(ch);
            }
            //实际输出的键去重存储
            for (int i = 0; i < fail.length(); i++) {
                char ch = fail.charAt(i);
                setFail.add(ch);
            }

            while (setFail.size() != 0) {
                char ch = setFail.pollFirst();
                setRight.remove(ch);
            }
            String target = "";

            for (int i = 0; i < right.length(); i++) {
                char ch = right.charAt(i);
                if (setRight.contains(ch)) {
                    target += ch + "";
                    setRight.remove(ch);
                }
            }


            System.out.println(target.toString().toUpperCase());
        }
    }
}
